const { merge } = require("webpack-merge");
const webpack = require("webpack");
const path = require("path");
const baseConfig = require("./webpack.common");
const WebpackBarPlugin = require("webpackbar");

/** @type {import('webpack-dev-server').Configuration} */
const devServerConfig = {
  port: 8080,
  hot: true,
  open: false
};

/** @type {import('webpack').Configuration} */
const config = {
  cache: {
    type: "filesystem",
  },
  mode: "development",
  entry: ['webpack-dev-server/client',"webpack/hot/dev-server", path.resolve(__dirname, "./src/main.js")],

  devServer: devServerConfig,
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          {
            loader: "style-loader",
          },
          {
            loader: "css-loader",
          },
        ],
      },
      {
        test: /\.less$/,
        use: [
          {
            loader: "style-loader",
          },
          {
            loader: "css-loader",
          },
          {
            loader: "less-loader",
          },
        ],
      },
    ],
  },
  plugins: [new webpack.HotModuleReplacementPlugin(), new WebpackBarPlugin()],
};
module.exports = merge(baseConfig, config);
